#include "sql_utili.h"

int main()
{
    printf("Content-Type:text/html; charset=utf-8\n\n");
    MYSQL mysql;
    mysql_init(&mysql);
    Connect_MySql(&mysql, "localhost", "root", "a123456", "info");
    
    char user_name[20] = {0};
    char user_passwd[10] = {0};
    parse_name_passwd(user_name, user_passwd);
    
    //得判断输入用户是否存在
    
    char sql[100] = {0};
    sprintf(sql, "select user_passwd from user_info where user_name=\"%s\"", user_name);
    //printf("sql = %s", sql);
   
    mysql_query(&mysql, sql);//语句错误需解决
    MYSQL_RES *mysql_res = mysql_use_result(&mysql);
    MYSQL_ROW sqlrow = mysql_fetch_row(mysql_res);

    //printf("sqlrow = %s",sqlrow[0]);
    if(strcmp(sqlrow[0], user_passwd) != 0)
    {
        printf("<h1 align=center>User Name or User_Password Error.</h1>");
        sleep(2);
        skip_page("../BigInt_CGI/htdocs/index.html");
    }
    else
    {
        //printf("success.");
        skip_page("../BigInt_CGI/htdocs/bigcalc.html");
    }

    mysql_close(&mysql);
    return 0;
}
